home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / rbbs_pc / r2dbf121.zip / CONVERT2.PAS < prev    next >
Pascal/Delphi Source File  |  1992-05-30  |  8KB  |  216 lines

  1. Program Convert2;
  2. { AUTHOR: (c)1989-1992, Eric J. Givler, All Rights Reserved }
  3.  
  4. Uses Crt,
  5.      Dos,
  6.      TPDB,
  7.      TPDBStr;
  8.  
  9. { The RBBS-PC USERS file contains information unique for each
  10.   RBBS-PC user who logs on.  It is a random file with 128-byte
  11.   records.  The layout of each users record within the USERS
  12.   file is as follows:
  13.  
  14. Position      Length  Description
  15.   1 - 31      31  Users first and last name (separated by a blank).
  16.  32 - 46      15  Users password for logon.
  17.  47 - 48       2  Users security level (permanent).
  18.  49 - 62      14  Users logon options (see detail breakdown below).
  19.  63 - 86      24  City and state from which the user is calling.
  20.  87 -105      19  ---- RESERVED FOR FUTURE USE ----
  21. 106 -119      14  Date and time the user was last on (MM-DD-YY HH:MM).
  22. 120 -122       3  Date the user last listed a directory.
  23. 123 -124       2  Number of downloads done by the user.
  24. 125 -126       2  Number of uploads done by the user.
  25. 127 -128       2  Elapsed time the user was on for day of last access. }
  26.  
  27. TYPE
  28.     FourByteArray = Array[1..4] of byte;
  29.     hexstr = string[4];
  30.  
  31.    UserRec = RECORD
  32.       Name       : ARRAY[1..31] OF CHAR;
  33.       PassWord   : ARRAY[1..15] OF CHAR;
  34.       SecLevel   : INTEGER;
  35.  
  36.       (* Options : ARRAY[1..14] OF CHAR; *)
  37.       TimesOn    : INTEGER;
  38.       LastMsg    : INTEGER;
  39.       Protocol   : CHAR;
  40.       Ug         : CHAR;
  41.       RMargin    : INTEGER;
  42.       Options    : INTEGER;
  43.       SubDate    : ARRAY[1..2] OF CHAR;    {?}
  44.       PageLength : CHAR;
  45.       Echoer     : CHAR;                     { I, C, R }
  46.  
  47.       CityState  : ARRAY[1..24] OF CHAR;
  48.       Machine    : ARRAY[1..3] OF BYTE;     (* Actually RESERVED   *)
  49.       DLToday    : FourByteArray;           (* number of downloads *)
  50.       BytesDL    : FourByteArray;           (* BYTES DL TODAY      *)
  51.       DLBytes    : FourByteArray;           (* total bytes DL EVER *)
  52.       ULBytes    : FourByteArray;           (* BYTES UL EVER       *)
  53.       DateTime   : ARRAY[1..14] OF CHAR;
  54.       LastDir    : ARRAY[1..3] OF BYTE;
  55.       DLS        : INTEGER;
  56.       ULS        : INTEGER;
  57.       ElapsedTime: INTEGER;
  58.    END;
  59.  
  60. VAR
  61.     User     : UserRec;
  62.     UserFile : File of UserRec;
  63.     IntStr   : String[2];
  64.     IntStr4  : String[4];
  65.     IntStr5  : String[5];
  66.     IntStr7  : String[7];
  67.     Ye,Mo,Da : Byte;
  68.     StrYe,
  69.     StrMo,
  70.     StrDa    : String[2];
  71.     TempStr  : String[8];
  72.     i        : integer;
  73.     Graphics : integer;
  74.     BigBool  : Boolean;
  75.     RBBS     : ^DBF;
  76.  
  77. { Basic2TP returns a longint of a QuickBASIC numeric stored as
  78.   a 4byte string.  QuickBASIC displays this via CVS() }
  79. FUNCTION Basic2TP(b4 : fourbytearray) : longint;
  80. var r :real;
  81.    b6 :array[0..5] of byte absolute r;
  82. begin
  83.     b6[0] := b4[4];
  84.     b6[1] := 0;
  85.     b6[2] := 0;
  86.     b6[3] := b4[1];
  87.     b6[4] := b4[2];
  88.     b6[5] := b4[3];
  89.     basic2TP := trunc(r);
  90. end;  {basic2TP}
  91.  
  92.  
  93. BEGIN
  94.    Writeln('CONVERT v1.21b, (c)1989-1992, E. Givler, All Rights Reserved.');
  95.    IF ParamCount <> 2 THEN Begin
  96.       Writeln('Syntax: CONVERT <UserFile> <File.DBF>');
  97.       Halt;
  98.    End;
  99.  
  100.    Assign(UserFile,ParamStr(1));
  101.    Reset(UserFile);
  102.    New(RBBS,Init(ParamStr(2)));
  103.    RBBS^.Zap;
  104.  
  105.    While NOT Eof(UserFile) Do Begin
  106.      Read(UserFile,User);
  107.      IF (Copy(User.Name,1,7) <> 'NEWUSER') AND (User.Name[1] <> #0) AND
  108.         (LENGTH(RTRIM(User.Name)) > 0) THEN Begin
  109.         RBBS^.NewDBRec;
  110.         RBBS^.Repl(1,COPY(User.Name, 1, POS(' ',User.Name) -1));
  111.         i := LENGTH(User.Name);  (* 31 *)
  112.         WHILE COPY(User.Name, i, 1) = ' ' DO i := i - 1;
  113.         RBBS^.Repl(2,COPY(User.Name, POS(' ',User.Name) + 1, i));
  114.         RBBS^.Repl(3,User.PassWord);
  115.         Str(User.SecLevel : 5 ,IntStr5);
  116.         RBBS^.Repl(4,IntStr5);
  117.         RBBS^.Repl(5,User.CityState);
  118.         RBBS^.Repl(6,User.DateTime);
  119.  
  120.         if User.LastDir[1] <> 32 then
  121.         begin
  122.             Ye := User.LastDir[1];
  123.             Mo := User.LastDir[2];
  124.             Da := User.LastDir[3];
  125.             Str(Ye : 2,StrYe);
  126.             Str(Mo : 2,StrMo);
  127.             Str(Da : 2,StrDa);
  128.             IF Ye < 10 THEN StrYe := '0'+LTRIM(StrYe);
  129.             IF Mo < 10 THEN StrMo := '0'+LTRIM(StrMo);
  130.             IF Da < 10 THEN StrDa := '0'+LTRIM(StrDa);
  131.             IF StrYe = '00' THEN StrYe := ' ';
  132.             IF StrMo = '00' THEN StrMo := ' ';
  133.             IF StrDa = '00' THEN StrDa := ' ';
  134.             TempStr := '19'+StrYe+StrMo+StrDa;
  135.         end
  136.         else
  137.             TempStr := '19800101';
  138.         IF (RTRIM(TempStr) = '19') THEN RBBS^.Repl(7,'19800101')
  139.            ELSE RBBS^.Repl(7,TempStr);
  140.  
  141.         Str(User.ULS : 5,IntStr5);
  142.         RBBS^.Repl(8,IntStr5);
  143.         Str(User.DLS : 5,IntStr5);
  144.         RBBS^.Repl(9,IntStr5);
  145.         Str(User.ElapsedTime : 5,IntStr5);
  146.         RBBS^.Repl(10,IntStr5);
  147.         Str(User.LastMsg : 5, IntStr5);
  148.         RBBS^.Repl(11, IntStr5);
  149.         Str(User.TimesOn : 5, IntStr5);
  150.         RBBS^.Repl(12, IntStr5);
  151.  
  152.         STR(Basic2TP(User.DLToday) : 2, IntStr);
  153.         RBBS^.Repl(13, IntStr);
  154.         STR(Basic2TP(User.BytesDL) : 7, IntStr7);
  155.         RBBS^.Repl(14, IntStr7);
  156.         STR(Basic2TP(User.DLBytes) : 8, TempStr);
  157.         RBBS^.Repl(15, TempStr);
  158.         STR(Basic2TP(User.ULBytes) : 8, TempStr);
  159.         RBBS^.Repl(16, TempStr);
  160.  
  161.         IF User.Echoer = ' ' THEN RBBS^.Repl(17, 'R')
  162.            ELSE RBBS^.Repl(17, User.Echoer);
  163.         BigBool := (User.Options AND 1) > 0;
  164.         IF BigBool THEN RBBS^.Repl(18, 'T') ELSE RBBS^.Repl(18, 'F');
  165.         BigBool := (User.Options AND 2) > 0;
  166.         IF BigBool THEN RBBS^.Repl(19, 'T') ELSE RBBS^.Repl(19, 'F');
  167.         BigBool := (User.Options AND 4) > 0;
  168.         IF BigBool THEN RBBS^.Repl(20, 'T') ELSE RBBS^.Repl(20, 'F');
  169.         BigBool := (User.Options AND 8) > 0;
  170.         IF BigBool THEN RBBS^.Repl(21, 'T') ELSE RBBS^.Repl(21, 'F');
  171.         BigBool := (User.Options AND 16) > 0;
  172.         IF BigBool THEN RBBS^.Repl(22, 'T') ELSE RBBS^.Repl(22, 'F');
  173.         BigBool := (User.Options AND 32) > 0;
  174.         IF BigBool THEN RBBS^.Repl(23, 'T') ELSE RBBS^.Repl(23, 'F');
  175.         BigBool := (User.Options AND 64) > 0;
  176.         IF BigBool THEN RBBS^.Repl(24, 'T') ELSE RBBS^.Repl(24, 'F');
  177.         BigBool := (User.Options AND 128) > 0;
  178.         IF BigBool THEN RBBS^.Repl(25, 'T') ELSE RBBS^.Repl(25, 'F');
  179.         BigBool := (User.Options AND 256) > 0;
  180.         IF BigBool THEN RBBS^.Repl(26, 'T') ELSE RBBS^.Repl(26, 'F');
  181.         BigBool := (User.Options AND 512) > 0;
  182.         IF BigBool THEN RBBS^.Repl(27, 'T') ELSE RBBS^.Repl(27, 'F');
  183.         BigBool := (User.Options AND 1024) > 0;
  184.         IF BigBool THEN RBBS^.Repl(28, 'T') ELSE RBBS^.Repl(28, 'F');
  185.         BigBool := (User.Options AND 2048) > 0;
  186.         IF BigBool THEN RBBS^.Repl(29, 'T') ELSE RBBS^.Repl(29, 'F');
  187.  
  188.         Str(User.RMargin : 5, IntStr5);
  189.         RBBS^.Repl(30, IntStr5);
  190.         Str(ORD(User.PageLength) : 2, IntStr);
  191.         RBBS^.Repl(31, IntStr);
  192.  
  193.         i := (ORD(User.SubDate[1]) AND NOT 1) div 2 + 1980;
  194.         Mo := (ord(user.subdate[2]) div 32) or
  195.               ((ord(user.subdate[1]) and 1) * 8);
  196.         Da := ord(user.subdate[2]) and not 224;
  197.         Str(i : 4, IntStr4);
  198.         Str(Mo : 2, StrMo);
  199.         Str(Da : 2, StrDa);
  200.         IF Mo < 10 Then StrMo := '0'+LTRIM(StrMo);
  201.         IF Da < 10 THEN StrDa := '0'+LTRIM(StrDa);
  202.         TempStr := IntStr4+StrMo+StrDa;
  203.         RBBS^.Repl(32,TempStr);
  204.  
  205.         Graphics := ORD(User.Ug);
  206.         Str(Graphics : 2, IntStr);
  207.         RBBS^.Repl(33, IntStr);
  208.         IF User.Protocol = ' ' THEN RBBS^.Repl(34, 'N')
  209.            ELSE RBBS^.Repl(34,User.Protocol);
  210.         RBBS^.AddDBRec;
  211.      End;
  212.    End;
  213.    Close(UserFile);
  214.    DISPOSE(RBBS,Done);
  215. END. { Convert2.pas }
  216.